
class Student {
    #id ;
    #name ;
    constructor(id,name){
        this.#id = id ;
        this.#name = name ;
    }
    get id(){
        console.log( `获取 id 属性的值` );
        return this.#id;
    }
    set id(value) {
        console.log( `为 id 属性赋值 ${value}` );
        this.#id = value ;
    }
    get name(){
        console.log( `获取 name 属性的值` );
        return this.#name;
    }
    set name(value) {
        console.log( `为 name 属性赋值 ${value}` );
        this.#name = value ;
    }
}

let s = new Student( 1 , '王燕' );
console.log( s.id );
console.log( s.name );

s.id = 2 ;
s.name = '王丽' ;

console.log( s.id );
console.log( s.name );

console.log( Object.getOwnPropertyNames( Student.prototype ) );